import request from "@Utils/webServerRequest"
import { store } from '~store'
/**
 *
 * @param {product_id:商品ID} data
 * @returns
 */
// 商品详情
export const getPayJifengList = () => {

    return request({
        url: `api/zhangfuai/priceConfigList`,
        method: "get",
        paramete: {
            type: 'jiance',
            status: 1
        }
    })
}

// 调用充值接口
export const getPayCode = (id) => {

    return request({
        url: `api/alipay/pay`,
        method: "post",
        paramete: {},
        data: {
            func_name: 'jiance',
            good_id: id,
            shop_id: store.getState().jinritemaiShops.userShopId || '',
            pay_type: 'ali',
            good_type: '1'
        },
        headers: {
            'Content-Type': 'application/json'
        }
    })
}

// 查询充值结果
export const getPayResult = (id) => {

    return request({
        url: `api/alipay/payResult`,
        method: "get",
        paramete: {
            out_trade_no: id
        },
        headers: {
            'Content-Type': 'application/json'
        }
    })
}

// 查询剩余积分
export const getJifeng = () => {

    return request({
        url: `api/shop/getShopInfo`,
        method: "get",
        paramete: {
            shop_id: store.getState().jinritemaiShops.userShopId || '',
        }
    })
}

// 检测当个商品
export const getJiance = (data) => {

    return request({
        url: `api/jiance/create`,
        method: "post",
        paramete: {},
        data: {
            shop_id: store.getState().jinritemaiShops.userShopId || '',
            // ItemId: id,
            // Imgurl: '',
            // NeedCheckLogo: true,
            ...data
        },
        headers: {
            'Content-Type': 'application/json'
        }
    })
}

// 批量检测
export const getJianceList = (jianceList) => {

    return request({
        url: `api/jiance/batch`,
        method: "post",
        paramete: {},
        data: {
            shop_id: store.getState().jinritemaiShops.userShopId || '',
            // ItemId: id,
            // Imgurl: '',
            jianceList
        },
        headers: {
            'Content-Type': 'application/json'
        }
    })
}

// 批量检测结果
export const getJianceResult = (id) => {

    return request({
        url: `api/jiance/batchResult`,
        method: "post",
        paramete: {

        },
        data: {
            shop_id: store.getState().jinritemaiShops.userShopId || '',
            batchId: id
        },
        headers: {
            'Content-Type': 'application/json'
        }
    })
}

// 获取需要消耗的积分数
export const getJianceScore = () => {

    return request({
        url: `api/shop/xiaohaojifen`,
        method: "get",
        paramete: {},
    })
}

// 检测历史记录
export const getJianceHistory = (data = {}) => {

    return request({
        url: `api/jiance/history`,
        method: "get",
        paramete: {
            ...data
        },
    })
}